package org.ch02.entity;

import java.lang.reflect.Constructor;
import java.text.Format;

/**
 * 实体对象 - 基于反射实现一些测试操作
 * <p></p>
 * 修饰符 - Modifier
 * <p></p>
 *
 * @author ZJL
 * @date 2025-03-17
 */
public class Student {
    /**
     * 属性 - 字段 - Field
     */
    private String name;
    private int age;
    private float weight;
    private static final double PI = 3.14;
    public String sex;
    protected double score;

    /**
     * 构造方法 - Construct
     */
    public Student() {
    }

    public Student(String name, int age, float weight) {
        this.name = name;
        this.age = age;
        this.weight = weight;
    }

//    public Student(String name, int age, Double weight) {
//        this.name = name;
//        this.age = age;
//        this.weight = Float.parseFloat(String.valueOf(weight));
//    }
    public Student(String name, int age,Double score) {
        this.name = name;
        this.age = age;
        this.score = score;
    }

    public Student(String name, Float weight) {
        this.name = name;
        this.age = 18;
        this.weight = weight;
    }

    private Student(String name) {
        this.name = name;
        this.age = 18;
        this.weight = 100;
    }

    public double getScore() {
        return score;
    }

    public void setScore(double score) {
        this.score = score;
    }

    /**
     * 方法 - Method
     *
     * @return
     */
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public float getWeight() {
        return weight;
    }

    public void setWeight(float weight) {
        this.weight = weight;
    }

    public void hello() {
        System.out.println("你好!");
    }

    private void sleep() {
        System.out.println("睡觉了！");
    }
    private String sleep(String address,int hour) {
        System.out.println("睡觉了！");
        return "睡饱了得好好学习，天天向上！";
    }

    public void sayHello(String who) {
        System.out.println("你好," + who);
    }

    public void sayHello(String who, int age) {
        System.out.println("你好," + who + "\n年龄" + age);
    }

    public int sum(int i, int j) {
        return i + j;
    }

    /**
     * 静态方法
     *
     * @param sth
     */
    public static void study(String sth) {
        System.out.printf("学习《%s》", sth);
    }

    public void show() {
        System.out.printf("姓名：%s;%n年龄：%d;%n体重：%.2f;%nPI:%.2f", this.getName(), this.getAge(), this.getWeight(), PI);
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", weight=" + weight +
                ", sex='" + sex + '\'' +
                ", score=" + score +
                '}';
    }
}
